home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
676-700
/
681
/
term
/
source.lha
/
EmulationPanel.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-09
|
8KB
|
291 lines
/*
** $Id: EmulationPanel.c,v 1.5 92/04/21 16:58:43 olsen Sta Locker: olsen $
** $Revision: 1.5 $
** $Date: 92/04/21 16:58:43 $
**
** Editing panel for emulation configuration
**
** Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
enum { GAD_SMOOTHSCROLL,GAD_WRAPCHARS,GAD_WRAPCURSOR,GAD_INSERTMODE,GAD_NEWLINE,
GAD_NUMKEYPAD,GAD_CURSORKEYS,GAD_FONTSCALE,GAD_USE,GAD_CANCEL };
#define WIDTH 367
#define HEIGHT 129
STATIC STRPTR ControlMode[3] =
{
NULL,
NULL,
NULL
};
STATIC STRPTR ScaleFontText[3] =
{
NULL,
NULL,
NULL
};
STATIC struct Gadget *
CreateAllGadgets(struct Configuration *Config,struct Gadget *GadgetArray[],struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
{
struct Gadget *Gadget;
struct NewGadget NewGadget;
UWORD Counter = 0;
LocalizeString(ControlMode,MSG_EMULATIONPANEL_STANDARD_MODE_TXT,MSG_EMULATIONPANEL_APPLICATION_MODE_TXT);
LocalizeString(ScaleFontText,MSG_EMULATIONPANEL_NORMAL_SCALE_TXT,MSG_EMULATIONPANEL_HALF_WIDTH_TXT);
memset(&NewGadget,0,sizeof(struct NewGadget));
if(Gadget = CreateContext(GadgetList))
{
NewGadget . ng_Width = 26;
NewGadget . ng_Height = 11;
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_SMOOTH_SCROLLING_GAD);
NewGadget . ng_TextAttr = &DefaultFont;
NewGadget . ng_VisualInfo = VisualInfo;
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = WIDTH - 10 - 196;
NewGadget . ng_TopEdge = 1 + TopEdge;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, !Config -> JumpScroll,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_WRAP_CHARACTERS_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> AutoWrap,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_WRAP_CURSOR_MOVES_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> CursorWrap,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_INSERT_MODE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> InsertChar,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_NEW_LINE_MODE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCB_Checked, Config -> NewLine,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_NUMERIC_KEYPAD_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
NewGadget . ng_Width = 196;
NewGadget . ng_Height = 12;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCY_Labels, ControlMode,
GTCY_Active, Config -> NumApp,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_CURSOR_KEYS_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCY_Labels, ControlMode,
GTCY_Active, Config -> CursorApp,
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_EMULATIONPANEL_FONT_SCALE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_TopEdge = NewGadget . ng_TopEdge + NewGadget . ng_Height + 1;
GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
GTCY_Labels, ScaleFontText,
GTCY_Active, Config -> FontScale,
TAG_DONE);
NewGadget . ng_Width = 88; /* NEW 52 */
NewGadget . ng_Height = 12;
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_USE_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_Flags = 0;
NewGadget . ng_LeftEdge = 10;
NewGadget . ng_TopEdge = HEIGHT - 3 - NewGadget . ng_Height;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
NewGadget . ng_GadgetText = LocaleString(MSG_GLOBAL_CANCEL_GAD);
NewGadget . ng_GadgetID = Counter;
NewGadget . ng_LeftEdge = WIDTH - 10 - NewGadget . ng_Width;
GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
GT_Underscore, '_',
TAG_DONE);
}
return(Gadget);
}
VOID
EmulationPanel(struct Configuration *Config)
{
struct Window *PanelWindow;
struct Gadget *GadgetList;
struct Gadget *GadgetArray[GAD_CANCEL + 1];
ClearCursor();
CopyMem(Config,&PrivateConfig,sizeof(struct Configuration));
if(CreateAllGadgets(Config,&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
{
if(PanelWindow = OpenWindowTags(NULL,
WA_Left, (Screen -> Width - WIDTH) >> 1,
WA_Top, (Screen -> Height - HEIGHT) >> 1,
WA_Width, WIDTH,
WA_Height, HEIGHT,
WA_Activate, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_CustomScreen,Screen,
WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | CHECKBOXIDCMP | CYCLEIDCMP,
WA_Title, LocaleString(MSG_EMULATIONPANEL_EMULATION_PREFERENCES_TXT),
TAG_DONE))
{
struct IntuiMessage *Massage;
ULONG Class,Code;
struct Gadget *Gadget;
BYTE Terminated = FALSE;
PushWindow(PanelWindow);
AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
GT_RefreshWindow(PanelWindow,NULL);
while(!Terminated)
{
WaitPort(PanelWindow -> UserPort);
while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
{
Class = Massage -> Class;
Code = Massage -> Code;
Gadget = (struct Gadget *)Massage -> IAddress;
GT_ReplyIMsg(Massage);
if(Class == IDCMP_VANILLAKEY)
KeySelect(GadgetArray,GAD_CANCEL,Code,PanelWindow,&Gadget,&Class,&Code);
if(Class == IDCMP_CLOSEWINDOW)
Terminated = TRUE;
GadCheck: if(Class == IDCMP_GADGETUP)
{
switch(Gadget -> GadgetID)
{
case GAD_USE: Terminated = TRUE;
Config -> JumpScroll = !GT_CHECKED(GadgetArray[GAD_SMOOTHSCROLL]);
Config -> AutoWrap = GT_CHECKED(GadgetArray[GAD_WRAPCHARS]);
Config -> CursorWrap = GT_CHECKED(GadgetArray[GAD_WRAPCURSOR]);
Config -> InsertChar = GT_CHECKED(GadgetArray[GAD_INSERTMODE]);
Config -> NewLine = GT_CHECKED(GadgetArray[GAD_NEWLINE]);
break;
case GAD_CANCEL: Terminated = TRUE;
CopyMem(&PrivateConfig,Config,sizeof(struct Configuration));
break;
case GAD_NUMKEYPAD: Config -> NumApp = Code;
break;
case GAD_CURSORKEYS: Config -> CursorApp = Code;
break;
case GAD_FONTSCALE: Config -> FontScale = Code;
break;
default: break;
}
}
}
}
RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
PopWindow();
CloseWindow(PanelWindow);
}
FreeGadgets(GadgetList);
}
if(PrivateConfig . FontScale == SCALE_HALF && Config -> FontScale != SCALE_HALF)
{
if(Config -> EightyColumns)
{
LastColumn = 79;
LastPixel = 80 * 8 - 1;
}
else
{
LastColumn = ((Window -> Width & ~7) / 8) - 1;
LastPixel = (Window -> Width & ~7) - 1;
}
}
if(PrivateConfig . FontScale != SCALE_HALF && Config -> FontScale == SCALE_HALF)
{
if(Config -> EightyColumns)
{
LastColumn = 131;
LastPixel = 80 * 8 - 1;
}
else
{
LastColumn = ((Window -> Width & ~7) / 4) - 1;
LastPixel = (Window -> Width & ~7) - 1;
}
}
SetCursor();
}